package com.kangfu.api.service.impl;


import com.kangfu.db.model.vo.BannerVo;
import com.kangfu.api.service.IBannerService;
import com.kangfu.db.domain.entity.Banner;
import com.kangfu.db.mapper.BannerMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 轮播图Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-08-10
 */
@Service
public class BannerServiceImpl implements IBannerService
{
    @Autowired
    private BannerMapper bannerMapper;

    /**
     * 查询轮播图列表
     *
     * @return 轮播图
     */
    @Override
    public List<BannerVo> selectBannerList(int type)
    {
        List<Banner> bannerList = bannerMapper.selectBannerList(type);
        List<BannerVo> bannerVos = new ArrayList<BannerVo>();
        if (bannerList != null) {
            for (Banner banner : bannerList) {
                BannerVo bannerVo = new BannerVo();
                bannerVo.setType(banner.getType());
                bannerVo.setRedirect(banner.getRedirect());
                bannerVo.setMiniProgramPage(banner.getMiniProgramPage());
                bannerVo.setRedirectUrl(banner.getRedirectUrl());
                bannerVo.setUrl(banner.getUrl());
                bannerVos.add(bannerVo);
            }
        }
        return bannerVos;
    }


}
